package com.shg.web.action.search;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.shg.bean.Book;
import com.shg.bean.PageView;
import com.shg.bean.QueryResult;
import com.shg.service.search.BookSearchService;

@Controller
public class BookSearchAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	//查询分类
	private Integer type=-1;
	//查询关键字
	private String keyWord;
	//当前页
	private int page=1;
	//查询的每页显示的最大记录
	private int maxResult=3;
	//查询显示
	private PageView<Book> pageView;
	@Resource
	BookSearchService bookSearchService;
	
	@Override
	public String execute() throws Exception {
		pageView=new PageView<Book>(maxResult, page);
		QueryResult<Book> queryResult=bookSearchService.getSearch(type,keyWord, pageView.getFirstResult(), pageView.getMaxrecord());
		pageView.setQueryResult(queryResult);
		return SUCCESS;
	}


	public Integer getType() {
		return type;
	}


	public void setType(Integer type) {
		this.type = type;
	}


	public String getKeyWord() {
		return keyWord;
	}

	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getMaxResult() {
		return maxResult;
	}

	public void setMaxResult(int maxResult) {
		this.maxResult = maxResult;
	}

	public PageView<Book> getPageView() {
		return pageView;
	}

	public void setPageView(PageView<Book> pageView) {
		this.pageView = pageView;
	}


}
